<?php

echo $this->smartButton('Dodaj kategorię główną', $this->url(array('controller' => 'offer-category', 'action' => 'add'), 'admin', true));

function renderActions($row, $view) {
    $html = $view->smartButton('Wyświetl', $view->url(array('controller' => 'offer', 'action' => 'index', 'id' => $row['code']), 'default', true), array('size' => 'mini', 'noAjax' => true));
    $html .= $view->smartButton('Usuń', $view->url(array('controller' => 'offer-category', 'action' => 'delete', 'id' => $row['code']), 'admin', true), array('size' => 'mini'));
    $html .= $view->smartButton('Edycja nazwy', $view->url(array('controller' => 'offer-category', 'action' => 'edit-general', 'id' => $row['code']), 'admin', true), array('size' => 'mini'));
    if($row['level'] == 1) {
        $html .= $view->smartButton('Dodaj podkategorię', $view->url(array('controller' => 'offer-category', 'action' => 'add', 'id' => $row['code']), 'admin', true), array('size' => 'mini'));
    } else {
        $html .= $view->smartButton('Edycja szablonu', $view->url(array('controller' => 'offer-template', 'action' => 'save', 'id' => $row['code']), 'admin', true), array('size' => 'mini'));
    }
    return $html;
}

echo $this->table($this->list, array(
    'Nazwa' => 'name',
    'Kolejność' => 'order_id',
    'Operacje' => array('eval' => 'renderActions($row, $view)')
        ),
        array(
            'rowClass' => 'tree-level-${item.level}',
        )
);
?>

<style type="text/css">
.table tr.tree-level-2 td:nth-child(2) {
    padding-left: 30px;
}
</style>